package com.health.fragment.tijian;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.health.NovaApplication;
import com.health.PersonalFileActivity.onFragmentSave;
import com.health.R;
import com.health.adapter.CheckBoxAdapter;
import com.health.adapter.CheckBoxAdapter_EatHobby;
import com.health.adapter.RadioButtonAdapter;
import com.health.db.FDbManager;
import com.health.fragment.NovaFragment;
import com.health.model.BD_DD_INFO_Checked;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.ARCHIVE_LIFESTYLE;
import com.health.tablebean.BD_DD_INFO;
import com.health.activity.tijian.TiJianActivity;
import com.health.tools.GlobalConts;
import com.health.view.spinner.NiceSpinner;
import com.health.view.spinner.NiceSpinnerAdapter;
import com.health.widget.MyGridView;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.RadioButton;

/**
 * 健康体检 生活方式
 * 
 * @author 鹿云龙
 */
public class HealthTiJian_ShfsFragment extends NovaFragment implements onFragmentSave {
	private ARCHIVE_BASEINFO userInfo;// 基本信息
	// private final static int I_NULL = -1;
	private ARCHIVE_LIFESTYLE lifeStyle;// 生活方式
	private View baseView = null;
	private NiceSpinner ns_exericse_rate;// 锻炼频率
	// private NiceSpinnerAdapter<BD_DD_INFO> nsExericseRateAdapter;//
	// 锻炼频率adapter
	private List<BD_DD_INFO> nsduanlianpinlv;
	private EditText et_duanlianshijian;// 每次锻炼时间
	private EditText etJianChi;// 坚持锻炼时间
	private EditText et_duanlianfangshi;// 锻炼方式
	private MyGridView eatHobby;// 饮食习惯
	private CheckBoxAdapter_EatHobby eatHobbyAdapter;// 饮食习惯adapter
	// 烟
	private NiceSpinner niceSpinnerXiYanqk;// 吸烟情况
	private List<BD_DD_INFO> nsxiyanQingKuangList;// 吸烟情况
	// private NiceSpinnerAdapter<BD_DD_INFO> xiyanqingkuangAdapter;
	private EditText et_shfs_rixiyanliang;// 日吸烟量
	private EditText et_shfs_kaishixiyannianling;// 开始吸烟年龄
	private EditText et_shfs_jieyannianling;// 戒烟年龄
	// 酒
	private NiceSpinner nsDrinkrate;// 饮酒频率
	// private NiceSpinnerAdapter<BD_DD_INFO> nsDrinkAdapter;
	private List<BD_DD_INFO> nsyinjiuPinLv;
	private EditText etDayDrinkVolume;// 日饮酒量
	private EditText etDrinkStartAge;// 开始饮酒年龄
	private MyGridView gv_shifoujiejiu;// 是否戒酒
	private EditText et_jiejiunianling;// 戒酒年龄
	private MyGridView mgvDrinkThisyear;// 最近一年是否醉酒
	private RadioButtonAdapter drinkThisyearAdapter;// 最近一年

	private MyGridView mgv_drink_type;// 饮酒种类
	private CheckBoxAdapter drinkTypeAdapter;// 饮酒种类
	private RadioButtonAdapter drink;// 是否戒酒

	// 职业病
	private EditText etWorkTime;// 工作时长
	private EditText etWorkType;// 工种

	private MyGridView mgv_career_harm;// 有无危害
	private ShfsRadioButtonAdapter career_harm_adapter;// 有无危害

	private EditText etDust;// 粉尘PROTECT
	private EditText etFangShe;// 放射性物质
	private EditText etPhysical;// 物理因素
	private EditText etChem;// 化学物质
	private EditText etOther;// 其他

	private EditText etDustProtect;// 防护措施
	private EditText etFangsheProtect;
	private EditText etPhysicalProtect;
	private EditText etChemProtect;
	private EditText etOtherProtect;

	private com.health.adapter.RadioButtonAdapter wh_dust;
	private com.health.adapter.RadioButtonAdapter wh_fangshe;
	private com.health.adapter.RadioButtonAdapter wh_physical;
	private com.health.adapter.RadioButtonAdapter wh_chem;
	private com.health.adapter.RadioButtonAdapter wh_other;

	private MyGridView mgvDustProtect;
	private MyGridView mgvFangsheProtect;
	private MyGridView mgvPhysicalProtect;
	private MyGridView mgvChemProtect;
	private MyGridView mgvOtherProtect;
	private int from;// 数据库中是否有数据 1：有数据 0：无数据

	private void initData() {

		List<ARCHIVE_LIFESTYLE> acs = FDbManager.getInstance(getActivity()).findAllByWhere(ARCHIVE_LIFESTYLE.class,
				"IDCARD = '" + userInfo.getIDCARD() + "'");
		if (acs.size() > 0) {
			from = 1;
			ARCHIVE_LIFESTYLE lifeStyle = acs.get(acs.size() - 1);
			career_harm_adapter.setChecked(lifeStyle.getCAREERHARMFACTORHISTORY());
			etChem.setText(lifeStyle.getCHEM());
			wh_chem.setChecked(lifeStyle.getCHEMPROTECT());
			etChemProtect.setText(lifeStyle.getCHEMPROTECT_EX());
			etDayDrinkVolume.setText(lifeStyle.getDAYDRINKVOLUME() + "");
			// nsDrinkrate.setText(text);

			int index_yjpl = getListIndex(lifeStyle.getDRINKRATE(), nsyinjiuPinLv);
			nsDrinkrate.setSelectedIndex(index_yjpl);// 吸烟状况1:从不吸烟,3:已戒烟,3:吸烟
			Log.e("tag", index_yjpl + "index_yjpl");
			Log.w("tttpos-index_yjpl--", "" + index_yjpl);
			if (index_yjpl == 0) {
				etDayDrinkVolume.setText("");
				etDrinkStartAge.setText("");
				et_jiejiunianling.setText("");

				setEditTextEnable(etDayDrinkVolume, false);
				setEditTextEnable(etDrinkStartAge, false);
				setEditTextEnable(et_jiejiunianling, false);
			} else {
				setEditTextEnable(etDayDrinkVolume, true);
				setEditTextEnable(etDrinkStartAge, true);
				setEditTextEnable(et_jiejiunianling, true);
			}
			drink.setChecked(lifeStyle.getISDRINKFORBIDDON());
			Log.e("tag", lifeStyle.getISDRINKFORBIDDON() + " lifeStyle.getISDRINKFORBIDDON()");

			etDrinkStartAge.setText(lifeStyle.getDRINKSTARTAGE() + "");
			drinkThisyearAdapter.setChecked(lifeStyle.getDRINKTHISYEAR());// 近一年内是否醉酒1:是,2:否
			drinkTypeAdapter.setChecked(lifeStyle.getDRINKTYPE());
			drinkTypeAdapter.setOther(lifeStyle.getDRINKTYPE_OTHER());

			etDust.setText(lifeStyle.getDUST());
			wh_dust.setChecked(lifeStyle.getDUSTPROTECT());
			etDustProtect.setText(lifeStyle.getDUSTPROTECT_EX());
			Log.e("ddddddddddd", lifeStyle.getEATHOBBY());
			eatHobbyAdapter.setChecked(lifeStyle.getEATHOBBY());
			etJianChi.setText(lifeStyle.getEXCISEPERSISTTIME() + "");
			et_duanlianfangshi.setText(lifeStyle.getEXERCISEEXISTENSE());
			int dlpvindex = getListIndex(lifeStyle.getEXERCISERATE(), nsduanlianpinlv);
			ns_exericse_rate.setSelectedIndex(dlpvindex);// TODO 锻炼频率
			if (dlpvindex == 3) {
				et_duanlianshijian.setText("");
				et_duanlianshijian.setEnabled(false);
				et_duanlianfangshi.setText("");
				et_duanlianfangshi.setEnabled(false);
				etJianChi.setText("");
				etJianChi.setEnabled(false);
			}

			et_duanlianshijian.setText(lifeStyle.getEXERCISETIME() + "");
			etFangShe.setText(lifeStyle.getFANGSHE());
			wh_fangshe.setChecked(lifeStyle.getFANGSHEPROTECT());
			etFangsheProtect.setText(lifeStyle.getFANGSHEPROTECT_EX());
			et_jiejiunianling.setText(lifeStyle.getFORBIDDONAGE() + "");
			Log.e("tag", lifeStyle.getFORBIDDONAGE() + " lifeStyle.getFORBIDDONAGE()");
			etOther.setText(lifeStyle.getOTHER());
			wh_other.setChecked(lifeStyle.getOTHERPROTECT());
			etOtherProtect.setText(lifeStyle.getOTHERPROTECT_EX());
			etPhysical.setText(lifeStyle.getPHYSICAL());
			wh_physical.setChecked(lifeStyle.getPHYSICALPROTECT());
			etPhysicalProtect.setText(lifeStyle.getPHYSICALPROTECT_EX());
			et_shfs_jieyannianling.setText(lifeStyle.getSMOKEAGEFORBIDDON() + "");
			et_shfs_kaishixiyannianling.setText(lifeStyle.getSMOKEAGESTART() + "");
			int index = getListIndex(lifeStyle.getSMOKECONDITION(), nsxiyanQingKuangList);
			niceSpinnerXiYanqk.setSelectedIndex(index);// 吸烟状况1:从不吸烟,3:已戒烟,3:吸烟
			if (index == 0) {
				et_shfs_rixiyanliang.setText("");
				et_shfs_kaishixiyannianling.setText("");
				et_shfs_jieyannianling.setText("");

				setEditTextEnable(et_shfs_rixiyanliang, false);
				setEditTextEnable(et_shfs_kaishixiyannianling, false);
				setEditTextEnable(et_shfs_jieyannianling, false);
			} else if (index == 2) {
				et_shfs_jieyannianling.setText("");
				setEditTextEnable(et_shfs_jieyannianling, false);
			} else {
				setEditTextEnable(et_shfs_rixiyanliang, true);
				setEditTextEnable(et_shfs_kaishixiyannianling, true);
				setEditTextEnable(et_shfs_jieyannianling, true);
			}
			et_shfs_rixiyanliang.setText(lifeStyle.getSMOKEDAYNUM() + "");
			etWorkTime.setText(lifeStyle.getWORKTIME() + "");
			etWorkType.setText(lifeStyle.getWORKTYPE());
		} else {
			wh_fangshe.checkedClose();

		}
		// yinJiuCheck(nsDrinkrate.getText());
	}

	/**
	 * 保存数据
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月22日 上午10:07:09
	 */
	private void saveData() {
		// String ssss = drinkThisyearAdapter.getChecked();
		// System.out.println(ssss);
		// {
		/* 验证信息 */
		// et_shfs_jieyannianling
		// if
		// ((!TextUtils.isEmpty(et_shfs_kaishixiyannianling.getText().toString()))
		// &&
		// (!TextUtils.isEmpty(et_shfs_jieyannianling.getText().toString())))
		// {
		if (!TextUtils.isEmpty(et_shfs_jieyannianling.getText().toString())
				&& !TextUtils.isEmpty(et_shfs_kaishixiyannianling.getText().toString())) {
			int kaishi = Integer.parseInt(et_shfs_kaishixiyannianling.getText().toString());
			int jieyan = Integer.parseInt(et_shfs_jieyannianling.getText().toString());
			if (jieyan < kaishi) {
				((TiJianActivity) getActivity()).showTextDialog("戒烟年龄不能小于开始吸烟年龄");
				return;
			}
		}
		
		if (!TextUtils.isEmpty(et_jiejiunianling.getText().toString())
				&& !TextUtils.isEmpty(etDrinkStartAge.getText().toString())) {
			int kaishi = Integer.parseInt(etDrinkStartAge.getText().toString());
			int jiejiu = Integer.parseInt(et_jiejiunianling.getText().toString());
			if (jiejiu < kaishi) {
				((TiJianActivity) getActivity()).showTextDialog("戒酒年龄不能小于开始喝酒年龄");
				return;
			}
		}
		// TODO:饮食习惯必填验证
		// if (TextUtils.isEmpty(eatHobbyAdapter.getCheckedIdsStr())) {
		// ((TiJianActivity) getActivity()).showTextDialog("请填写饮食习惯");
		// return;
		// }

		// if (TextUtils.isEmpty(career_harm_adapter.getChecked())) {
		// ((TiJianActivity) getActivity()).showTextDialog("请填写有无危害");
		// return;
		// }
		lifeStyle = new ARCHIVE_LIFESTYLE();
		lifeStyle.setCAREERHARMFACTORHISTORY(career_harm_adapter.getChecked());// 职业病危害因素接触史1:无,2:有//career_harm
		lifeStyle.setCHEM(etChem.getText().toString());
		lifeStyle.setCHEMPROTECT(wh_chem.getChecked());
		lifeStyle.setCHEMPROTECT_EX(etChemProtect.getText().toString());
		String ddv = etDayDrinkVolume.getText().toString();
		lifeStyle.setDAYDRINKVOLUME(ddv);
		lifeStyle.setDRINKRATE(nsyinjiuPinLv.get(nsDrinkrate.getSelectedIndex()).getID());
		String dsa = etDrinkStartAge.getText().toString();
		lifeStyle.setDRINKSTARTAGE(dsa);
		lifeStyle.setDRINKTHISYEAR(drinkThisyearAdapter.getChecked());
		String str = drinkTypeAdapter.getCheckedIdsStr();
		System.out.println(str);
		System.out.println(str);
		lifeStyle.setDRINKTYPE(drinkTypeAdapter.getCheckedIdsStr());
		lifeStyle.setDRINKTYPE_OTHER(drinkTypeAdapter.getOther());
		lifeStyle.setDUST(etDust.getText().toString());
		lifeStyle.setDUSTPROTECT(wh_dust.getChecked());
		lifeStyle.setDUSTPROTECT_EX(etDustProtect.getText().toString());
		lifeStyle.setEATHOBBY(eatHobbyAdapter.getCheckedIdsStr());
		String jc = etJianChi.getText().toString();
		lifeStyle.setEXCISEPERSISTTIME(jc);
		lifeStyle.setEXERCISEEXISTENSE(et_duanlianfangshi.getText().toString());
		lifeStyle.setEXERCISERATE(nsduanlianpinlv.get(ns_exericse_rate.getSelectedIndex()).getID());// 锻炼频率
		String esdlsj = et_duanlianshijian.getText().toString();
		lifeStyle.setEXERCISETIME(esdlsj);
		lifeStyle.setFANGSHE(etFangShe.getText().toString());
		lifeStyle.setFANGSHEPROTECT(wh_fangshe.getChecked());
		lifeStyle.setFANGSHEPROTECT_EX(etFangsheProtect.getText().toString());
		String strjjnl = et_jiejiunianling.getText().toString();
		lifeStyle.setFORBIDDONAGE(strjjnl);// 戒酒年龄
		lifeStyle.setCAREERHARMFACTORHISTORY(career_harm_adapter.getChecked()); //
		// 职业病危害因素接触史1:无,2:有
		lifeStyle.setISDRINKFORBIDDON(drink.getChecked());// 是否戒酒1:未戒酒,2:已戒酒
		String jynl = et_shfs_jieyannianling.getText().toString();
		lifeStyle.setSMOKEAGEFORBIDDON(jynl);// 戒烟年龄

		lifeStyle.setIDCARD(userInfo.getIDCARD());// 身份证
		lifeStyle.setOTHER(etOther.getText().toString());
		lifeStyle.setOTHERPROTECT(wh_other.getChecked());
		lifeStyle.setOTHERPROTECT_EX(etOtherProtect.getText().toString());
		lifeStyle.setPHYSICAL(etPhysical.getText().toString());
		// lifeStyle.setPHYSICALID(pHYSICALID);//没用
		lifeStyle.setPHYSICALPROTECT(wh_physical.getChecked());// 物理防护措施,有无
		lifeStyle.setPHYSICALPROTECT_EX(etPhysicalProtect.getText().toString());// 物理防护措施
		String strJynl = et_shfs_jieyannianling.getText().toString();
		lifeStyle.setSMOKEAGEFORBIDDON(strJynl);
		String ksxy = et_shfs_kaishixiyannianling.getText().toString();
		lifeStyle.setSMOKEAGESTART(ksxy);
		// lifeStyle.setSMOKECONDITION(xiyanqingkuangAdapter.getItem(niceSpinnerXiYanqk.getSelectedIndex()).getID());//
		// TODO 吸烟状况
		lifeStyle.setSMOKECONDITION(nsxiyanQingKuangList.get(niceSpinnerXiYanqk.getSelectedIndex()).getID());
		String rxyl = et_shfs_rixiyanliang.getText().toString();
		lifeStyle.setSMOKEDAYNUM(rxyl);
		String strwt = etWorkTime.getText().toString();
		lifeStyle.setWORKTIME(strwt);
		lifeStyle.setWORKTYPE(etWorkType.getText().toString());

		if (from == 1) {
			lifeStyle.setUPDATEORG(userInfo.getUPDATEORG());
			lifeStyle.setMODIFIED(userInfo.getCREATER());
			FDbManager.getInstance(getActivity()).updata(lifeStyle, "IDCARD='" + userInfo.getIDCARD() + "'");
		} else {
			lifeStyle.setCREATEORG(userInfo.getCREATEORG());
			lifeStyle.setCREATER(userInfo.getCREATER());
			FDbManager.getInstance(getActivity()).save(lifeStyle);
			from = 1;
		}
		((TiJianActivity) getActivity()).showTextDialog("保存成功");
	}

	public int getListIndex(String id, List<BD_DD_INFO> bds) {
		int index = 0;
		try {
			for (int i = 0; i < bds.size(); i++) {
				if (id.equals(bds.get(i).getID())) {
					index = i;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return index;
	}

	@Override
	public View findViews(LayoutInflater inflater) {
		userInfo = NovaApplication.getUserInfo();
		baseView = inflater.inflate(R.layout.fragment_healthtijian_shfs, null);

		ns_exericse_rate = (NiceSpinner) baseView.findViewById(R.id.ns_exericse_rate);
		et_duanlianshijian = (EditText) baseView.findViewById(R.id.et_duanlianshijian);
		eatHobby = (MyGridView) baseView.findViewById(R.id.eat_hobby);
		etJianChi = (EditText) baseView.findViewById(R.id.et_excise_persist_time);
		// spinner_xiyanqingkuang
		niceSpinnerXiYanqk = (NiceSpinner) baseView.findViewById(R.id.spinner_xiyanqingkuang);
		et_shfs_rixiyanliang = (EditText) baseView.findViewById(R.id.et_shfs_rixiyanliang);
		et_shfs_kaishixiyannianling = (EditText) baseView.findViewById(R.id.et_shfs_kaishixiyannianling);
		et_shfs_jieyannianling = (EditText) baseView.findViewById(R.id.et_shfs_jieyannianling);
		et_duanlianfangshi = (EditText) baseView.findViewById(R.id.et_duanlianfangshi);
		// 饮酒
		nsDrinkrate = (NiceSpinner) baseView.findViewById(R.id.ns_drinkrate);
		etDayDrinkVolume = (EditText) baseView.findViewById(R.id.et_day_drink_volume);
		etDrinkStartAge = (EditText) baseView.findViewById(R.id.et_drink_start_age);
		gv_shifoujiejiu = (MyGridView) baseView.findViewById(R.id.shifoujiejiu);
		et_jiejiunianling = (EditText) baseView.findViewById(R.id.et_jiejiunianling);
		mgvDrinkThisyear = (MyGridView) baseView.findViewById(R.id.mgv_drink_thisyear);
		mgv_drink_type = (MyGridView) baseView.findViewById(R.id.drink_type);
		mgv_career_harm = (MyGridView) baseView.findViewById(R.id.career_harm);
		// 职业病
		etWorkType = (EditText) baseView.findViewById(R.id.et_worktype);
		etWorkTime = (EditText) baseView.findViewById(R.id.et_worktime);

		etDust = (EditText) baseView.findViewById(R.id.et_dust);// 粉尘PROTECT
		etFangShe = (EditText) baseView.findViewById(R.id.et_fangshes);// 放射性物质
		etPhysical = (EditText) baseView.findViewById(R.id.et_physical);// 物理因素
		etChem = (EditText) baseView.findViewById(R.id.et_chem);// 化学物质
		etOther = (EditText) baseView.findViewById(R.id.et_other);// 其他

		etDustProtect = (EditText) baseView.findViewById(R.id.et_dust_protect);
		etFangsheProtect = (EditText) baseView.findViewById(R.id.et_fangshe_protect);
		etPhysicalProtect = (EditText) baseView.findViewById(R.id.et_physical_protect);
		etChemProtect = (EditText) baseView.findViewById(R.id.et_chem_protect);
		etOtherProtect = (EditText) baseView.findViewById(R.id.et_other_protect);

		mgvDustProtect = (MyGridView) baseView.findViewById(R.id.mgv_dust_protect);
		mgvFangsheProtect = (MyGridView) baseView.findViewById(R.id.mgv_fangshe_protect);
		mgvPhysicalProtect = (MyGridView) baseView.findViewById(R.id.mgv_physical_protect);
		mgvChemProtect = (MyGridView) baseView.findViewById(R.id.mgv_chem_protect);
		mgvOtherProtect = (MyGridView) baseView.findViewById(R.id.mgv_other_protect);

		nsDrinkrate.addTextChangedListener(new TextWatcher() {
			/**
			 * @param s
			 * @param start
			 * @param before
			 * @param count
			 */
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				yinJiuCheck(s);
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});

		// setmaxlength();

		GlobalConts.setMaxLength(3, et_duanlianshijian, etJianChi, et_shfs_rixiyanliang, et_shfs_kaishixiyannianling,
				et_shfs_jieyannianling, etDayDrinkVolume, etDrinkStartAge, et_jiejiunianling, etWorkTime);
		GlobalConts.setMaxLength(50, et_duanlianfangshi, etDust, etFangShe, etPhysical, etChem, etOther,

				etDustProtect, etFangsheProtect, etPhysicalProtect, etChemProtect, etOtherProtect);
		GlobalConts.setMaxLength(35, etWorkType);

		bindTiYuDuanLianData();
		bindYinShiXiGuan();
		bindXiYan();
		bindYinJiu();
		drink.canCheck(false);
		drinkThisyearAdapter.canCheck(false);// 最近一年
		drinkTypeAdapter.canChecked(false);
		bindZhiYeBing();
		initZYBView(wh_dust, etDust);
		initZYBView(wh_fangshe, etFangShe);
		initZYBView(wh_physical, etPhysical);
		initZYBView(wh_other, etOther);
		initZYBView(wh_chem, etChem);
		initData();
		return baseView;
	}

	/**
	 * 修改职业病中粉尘等RadioButton的状态
	 */
	public void initZYBView(final RadioButtonAdapter adapter, EditText et) {
		adapter.checkedClose();
		et.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if (s != null && count != 0) {

					adapter.checkOpen();
				} else {
					adapter.checkedClose();
				}

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {

			}
		});

	}

	@SuppressLint("UseSparseArrays")
	/**
	 * 初始化体育锻炼
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月18日 上午10:45:15
	 */
	private void bindTiYuDuanLianData() {
		List<BD_DD_INFO> pinLvList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-05' order by cast(SORT as int) asc");
		// nsExericseRateAdapter = new
		// NiceSpinnerAdapter<BD_DD_INFO>(getActivity(), pinLvList);
		// ns_exericse_rate.setAdapter(nsExericseRateAdapter);
		ns_exericse_rate.attachDataSource(getInfo(pinLvList));
		nsduanlianpinlv = pinLvList;
		ns_exericse_rate.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				if (position == 3) {
					et_duanlianshijian.setText("");
					et_duanlianfangshi.setText("");
					etJianChi.setText("");
					et_duanlianshijian.setEnabled(false);
					et_duanlianfangshi.setEnabled(false);
					etJianChi.setEnabled(false);
					// drinkTypeAdapter.setChecked("");
					// drinkTypeAdapter.setWuZhengZhuangChecked(true);
					// drinkTypeAdapter.notifyDataSetChanged();
					drinkTypeAdapter.clear();
				} else {
					et_duanlianshijian.setEnabled(true);
					et_duanlianfangshi.setEnabled(true);
					etJianChi.setEnabled(true);
				}

			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		// ns_exericse_rate.attachDataSource(getInfo(pinLvList));// 锻炼频率
		// DM08-3//坚持锻炼时间
		// 锻炼方式

	}

	/**
	 * 初始化饮食习惯
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月18日 上午10:45:46
	 */
	private void bindYinShiXiGuan() {
		// 饮食习惯//DM100-06
		List<BD_DD_INFO> yishixiguan = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-06' order by cast(SORT as int) asc");
		eatHobbyAdapter = new CheckBoxAdapter_EatHobby((TiJianActivity) getActivity(), yishixiguan);
		eatHobby.setAdapter(eatHobbyAdapter);
	}

	/**
	 * 初始化吸烟情况
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月18日 上午10:46:00
	 */
	private void bindXiYan() {
		nsxiyanQingKuangList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-07' order by cast(SORT as int) asc");
		// niceSpinnerXiYanqk.setAdapter(xiyanqingkuangAdapter);// 吸烟状况
		niceSpinnerXiYanqk.attachDataSource(getInfo(nsxiyanQingKuangList));// 吸烟状况
		niceSpinnerXiYanqk.setOnItemSelectedListener(new OnItemSelectedListener() {
			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO et_shfs_rixiyanliang

				Log.w("spinnner-------------pos", "" + position);

				et_shfs_rixiyanliang.setText("");
				et_shfs_kaishixiyannianling.setText("");
				et_shfs_jieyannianling.setText("");
				if (position == 0) {
					setEditTextEnable(et_shfs_rixiyanliang, false);
					setEditTextEnable(et_shfs_kaishixiyannianling, false);
					setEditTextEnable(et_shfs_jieyannianling, false);
				} else {
					setEditTextEnable(et_shfs_rixiyanliang, true);
					setEditTextEnable(et_shfs_kaishixiyannianling, true);
					if (position == 1) {
						setEditTextEnable(et_shfs_jieyannianling, true);
					} else {
						setEditTextEnable(et_shfs_jieyannianling, false);
					}
				}

			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// et_shfs_rixiyanliang.setText("");
				// et_shfs_rixiyanliang.setEnabled(false);
				// et_shfs_kaishixiyannianling.setText("");
				// et_shfs_kaishixiyannianling.setEnabled(false);
				// et_shfs_jieyannianling.setText("");
				// et_shfs_jieyannianling.setEnabled(false);
			}
		});
	}

	/**
	 * 通过id获取下拉框的位置
	 * 
	 * @param id
	 * @param nsa
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月23日 上午9:03:56
	 */
	public int getNiceSpinnerIndex(String id, NiceSpinnerAdapter<BD_DD_INFO> nsa) {
		int index = 0;
		for (int i = 0; i < nsa.getCount(); i++) {
			if (id.equals(nsa.getItem(i).getID())) {
				index = i;
			}
		}
		return index;
	}

	/**
	 * 初始化饮酒情况
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月18日 上午10:51:02
	 */
	private void bindYinJiu() {
		nsyinjiuPinLv = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-08' order by cast(SORT as int) asc");
		// nsDrinkAdapter = new NiceSpinnerAdapter<>(getActivity(), pinLvList);
		// nsDrinkrate.setAdapter(nsDrinkAdapter);// 饮酒频率
		nsDrinkrate.attachDataSource(getInfo(nsyinjiuPinLv));

		nsDrinkrate.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				Log.w("tttpos---", "" + position);
				if (nsyinjiuPinLv.get(position).getDATAINFO().equals("从不")) {
					etDayDrinkVolume.setText("");
					etDrinkStartAge.setText("");
					et_jiejiunianling.setText("");
					setEditTextEnable(etDayDrinkVolume, false);
					setEditTextEnable(etDrinkStartAge, false);
					setEditTextEnable(et_jiejiunianling, false);

					// gv_shifoujiejiu
					drink.canCheck(false);
					drinkThisyearAdapter.canCheck(false);
				} else {
					setEditTextEnable(etDayDrinkVolume, true);
					setEditTextEnable(etDrinkStartAge, true);
					setEditTextEnable(et_jiejiunianling, true);

					drink.canCheck(true);
					drinkThisyearAdapter.canCheck(true);
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		// 是否戒酒
		List<BD_DD_INFO> shifoujiejiu = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-09' order by cast(SORT as int) asc");
		drink = new RadioButtonAdapter(shifoujiejiu, getActivity(), et_jiejiunianling);
		drink.setOtherTextVisible(false);
		gv_shifoujiejiu.setAdapter(drink);

		// DM02-11
		List<BD_DD_INFO> yinjiuzhonglie = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM02-11' order by cast(SORT as int) asc");
		drinkTypeAdapter = new CheckBoxAdapter(getActivity(), yinjiuzhonglie);
		drinkTypeAdapter.setOtherMaxLength(10);
		mgv_drink_type.setAdapter(drinkTypeAdapter);
		// DM01-10_1是否醉酒
		List<BD_DD_INFO> shifouzuijiu = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID= 'DM01-10' order by cast(SORT as int) asc");
		List<BD_DD_INFO_Checked> checkeds = bindRadioButton(shifouzuijiu);
		drinkThisyearAdapter = new RadioButtonAdapter(getActivity(), checkeds);
		drinkThisyearAdapter.setOtherTextVisible(false);
		mgvDrinkThisyear.setAdapter(drinkThisyearAdapter);

	}

	/**
	 * 职业病
	 * 
	 * @author 鹿云龙
	 * @date 2015年12月18日 下午5:16:42
	 */
	private void bindZhiYeBing() {
		List<BD_DD_INFO> shifouyouhai = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-11' order by cast(SORT as int) asc");

		career_harm_adapter = new ShfsRadioButtonAdapter(getActivity(), bindRadioButton(shifouyouhai));
		mgv_career_harm.setAdapter(career_harm_adapter);

		List<BD_DD_INFO> fanghucuoshi = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-11' order by cast(SORT as int) asc");

		wh_dust = new RadioButtonAdapter(fanghucuoshi, getActivity(), etDustProtect);
		wh_fangshe = new RadioButtonAdapter(fanghucuoshi, getActivity(), etFangsheProtect);
		wh_physical = new RadioButtonAdapter(fanghucuoshi, getActivity(), etPhysicalProtect);
		wh_chem = new RadioButtonAdapter(fanghucuoshi, getActivity(), etChemProtect);
		wh_other = new RadioButtonAdapter(fanghucuoshi, getActivity(), etOtherProtect);

		wh_dust.setOtherTextVisible(false);
		wh_fangshe.setOtherTextVisible(false);
		wh_physical.setOtherTextVisible(false);
		wh_chem.setOtherTextVisible(false);
		wh_other.setOtherTextVisible(false);

		mgvDustProtect.setAdapter(wh_dust);
		mgvFangsheProtect.setAdapter(wh_fangshe);
		mgvPhysicalProtect.setAdapter(wh_physical);
		mgvChemProtect.setAdapter(wh_chem);
		mgvOtherProtect.setAdapter(wh_other);

		// wh_dust.sette
		// wh_fangshe
		// wh_physical
		// wh_chem
		// wh_other

	}

	/**
	 * 获取BD_DD_INFO s的BD_DD_INFO_Checked s
	 * 
	 * @param listZZs
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月18日 下午3:38:40
	 */
	public List<BD_DD_INFO_Checked> bindRadioButton(List<BD_DD_INFO> listZZs) {
		// List<BD_DD_INFO> listZZs=
		// fdbmanger.findAllByWhereInInfoDB(BD_DD_INFO.class,
		// "PARENTID='DM01-11'");
		List<BD_DD_INFO_Checked> list_check = new ArrayList<BD_DD_INFO_Checked>();
		int size = listZZs.size();
		if (size > 0) {
			for (int i = 0; i < size; i++) {
				BD_DD_INFO_Checked check = new BD_DD_INFO_Checked();
				check.setIsChecked(false);
				check.setBd_info(listZZs.get(i));
				check.setContent("");
				list_check.add(check);
			}
		}
		return list_check;
	}

	private void wuweihai() {
		etWorkTime.setText("");
		etWorkType.setText("");

		etDust.setText("");// 粉尘PROTECT
		etFangShe.setText("");// 放射性物质
		etPhysical.setText("");// 物理因素
		etChem.setText("");// 化学物质
		etOther.setText("");// 其他


		etWorkTime.setInputType(InputType.TYPE_NULL);
		etWorkType.setInputType(InputType.TYPE_NULL);
		etDust.setInputType(InputType.TYPE_NULL);
		etFangShe.setInputType(InputType.TYPE_NULL);
		etPhysical.setInputType(InputType.TYPE_NULL);
		etChem.setInputType(InputType.TYPE_NULL);
		etOther.setInputType(InputType.TYPE_NULL);
		etWorkTime.setEnabled(false);
		etWorkType.setEnabled(false);

		etDustProtect.setText("");// 防护措施
		etFangsheProtect.setText("");
		etPhysicalProtect.setText("");
		etChemProtect.setText("");
		etOtherProtect.setText("");
		etDustProtect.setInputType(InputType.TYPE_NULL);
		etFangsheProtect.setInputType(InputType.TYPE_NULL);
		etPhysicalProtect.setInputType(InputType.TYPE_NULL);
		etChemProtect.setInputType(InputType.TYPE_NULL);
		etOtherProtect.setInputType(InputType.TYPE_NULL);
	}

	public void youweihai() {
		etWorkTime.setInputType(InputType.TYPE_CLASS_NUMBER);
		etWorkType.setInputType(InputType.TYPE_CLASS_TEXT);
		etDust.setInputType(InputType.TYPE_CLASS_TEXT);
		etFangShe.setInputType(InputType.TYPE_CLASS_TEXT);
		etPhysical.setInputType(InputType.TYPE_CLASS_TEXT);
		etChem.setInputType(InputType.TYPE_CLASS_TEXT);
		etOther.setInputType(InputType.TYPE_CLASS_TEXT);
		etDustProtect.setInputType(InputType.TYPE_CLASS_TEXT);
		etFangsheProtect.setInputType(InputType.TYPE_CLASS_TEXT);
		etPhysicalProtect.setInputType(InputType.TYPE_CLASS_TEXT);
		etChemProtect.setInputType(InputType.TYPE_CLASS_TEXT);
		etOtherProtect.setInputType(InputType.TYPE_CLASS_TEXT);

		etWorkTime.setEnabled(true);
		etWorkType.setEnabled(true);
		wh_dust.checkOpen();
		wh_fangshe.checkOpen();
		wh_physical.checkOpen();
		wh_chem.checkOpen();
		wh_other.checkOpen();
	}

	/**
	 * 获取数据info
	 * 
	 * @param bds
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月18日 下午3:04:24
	 */
	public ArrayList<String> getInfo(List<BD_DD_INFO> bds) {
		ArrayList<String> infos = new ArrayList<String>();
		for (BD_DD_INFO bdi : bds) {
			infos.add(bdi.getDATAINFO());
		}
		return infos;
	}

	@Override
	public void setupView(View view) {
	}

	@Override
	public void addListener() {
		ChecYear(etJianChi);
		ChecYear(et_shfs_kaishixiyannianling);
		ChecYear(et_shfs_jieyannianling);
		ChecYear(etDrinkStartAge);
		ChecYear(et_jiejiunianling);
	}

	@Override
	public void setData() {
	}

	/**
	 * 对DB_DD_INFO数据进行排序
	 * 
	 * @param dataList
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月16日 上午11:30:44
	 */
	@SuppressLint("UseSparseArrays")
	public static ArrayList<BD_DD_INFO> bdDdInfoSort(List<BD_DD_INFO> dataList) {
		HashMap<Integer, BD_DD_INFO> dbmap = new HashMap<Integer, BD_DD_INFO>();
		ArrayList<BD_DD_INFO> datalist = new ArrayList<BD_DD_INFO>();

		for (BD_DD_INFO bd : dataList) {
			dbmap.put(Integer.parseInt(bd.getSORT()), bd);
		}
		for (int i = 1; i < dbmap.size(); i++) {
			datalist.add(dbmap.get(i));
		}
		return datalist;
	}

	/**
	 * 返回排序后的数据信息
	 * 
	 * @param dataList
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月16日 上午11:29:36
	 */
	@SuppressLint("UseSparseArrays")
	public static ArrayList<String> bdDdInfoDataSort(List<BD_DD_INFO> dataList) {
		HashMap<Integer, BD_DD_INFO> dbmap = new HashMap<Integer, BD_DD_INFO>();
		ArrayList<String> datalist = new ArrayList<String>();

		for (BD_DD_INFO bd : dataList) {
			dbmap.put(Integer.parseInt(bd.getSORT()), bd);
		}
		for (int i = 1; i <= dbmap.size(); i++) {
			datalist.add(dbmap.get(i).getDATAINFO());
		}
		return datalist;
	}

	//
	// }

	/**
	 * 单选
	 * 
	 * @author Administrator
	 *
	 */
	class ShfsRadioButtonAdapter extends BaseAdapter implements OnCheckedChangeListener {

		public List<BD_DD_INFO_Checked> list_check = new ArrayList<BD_DD_INFO_Checked>();
		private BD_DD_INFO_Checked tempGridViewItem;
		private LayoutInflater layoutInflater;
		private boolean check;

		/**
		 * 是否可以选中
		 * 
		 * @param check
		 * @author 鹿云龙
		 * @date 2016年2月2日 下午3:17:28
		 */
		public void setCheck(boolean check) {
			this.check = check;
		}

		public ShfsRadioButtonAdapter(Context context, List<BD_DD_INFO_Checked> list_check) {

			this.list_check = list_check;
			layoutInflater = LayoutInflater.from(context);

		}

		private EditText edittext;

		public ShfsRadioButtonAdapter(Context context, List<BD_DD_INFO_Checked> list_check, EditText edittext) {
			this.edittext = edittext;
			this.list_check = list_check;
			layoutInflater = LayoutInflater.from(context);

		}

		/**
		 * 数据总数
		 */
		@Override
		public int getCount() {
			return list_check.size();
		}

		/**
		 * 获取当前数据
		 */
		@Override
		public Object getItem(int position) {
			return list_check.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView, ViewGroup parent) {
			RadioButtonViewHolder avh = null;
			if (convertView == null) {
				convertView = layoutInflater.inflate(R.layout.radiobuttonitem, null);
				// TextView textView = (TextView) view.findViewById(R.id.title);
				avh = new RadioButtonViewHolder();
				avh.rbButton = (RadioButton) convertView.findViewById(R.id.radiobutton);
				avh.otherText = (EditText) convertView.findViewById(R.id.othertext);
				// convertView.setTag(avh);
				convertView.setTag(R.id.TAG_VIEWHOLDER, avh);
			} else {
				avh = (RadioButtonViewHolder) convertView.getTag(R.id.TAG_VIEWHOLDER);
			}

			setData(avh, position);
			return convertView;
		}

		/**
		 * 获取选中项的主键id
		 * 
		 * @return
		 * @author 鹿云龙
		 * @date 2015年12月22日 上午11:58:46
		 */
		public String getChecked() {
			String str = "";
			for (BD_DD_INFO_Checked bdic : list_check) {
				if (bdic.getIsChecked()) {
					str = bdic.getBd_info().getID();
				}
			}
			return str;
		}

		/**
		 * 获取选中项的对象
		 * 
		 * @return
		 * @author 鹿云龙
		 * @date 2015年12月22日 上午11:58:46
		 */
		public BD_DD_INFO getCheckedBD() {
			for (BD_DD_INFO_Checked bdic : list_check) {
				if (bdic.getIsChecked()) {
					return bdic.getBd_info();
				}
			}
			return null;
		}

		/**
		 * 设置选中项id 和其他数据
		 * 
		 * @param id
		 *            主键id
		 * @author 鹿云龙
		 * @date 2015年12月22日 下午12:00:45
		 */
		public void setChecked(String id, String Other) {
			for (BD_DD_INFO_Checked bdcheck : list_check) {

				String str_sjxtId_1 = bdcheck.getBd_info().getID();
				Log.w("dddddddddddd", str_sjxtId_1);
				if (str_sjxtId_1.equals(id)) {
					bdcheck.setIsChecked(true);
					bdcheck.setContent(Other);
					break;
				}
			}
		}

		/**
		 * 清除选中项
		 * 
		 * @author 鹿云龙
		 * @date 2015年12月22日 下午3:05:00
		 */
		public void checkedClear() {
			// for (BD_DD_INFO_Checked bdcheck : list_check) {
			// bdcheck.setIsChecked(false);
			// }
			wh_dust.checkedClose();
			wh_fangshe.checkedClose();
			wh_physical.checkedClose();
			wh_chem.checkedClose();
			wh_other.checkedClose();
		}

		/**
		 * 设置选中项id
		 * 
		 * @param id
		 *            主键id
		 * @author 鹿云龙
		 * @date 2015年12月22日 下午12:00:45
		 */
		public void setChecked(String id) {
			for (BD_DD_INFO_Checked bdcheck : list_check) {
				String str_sjxtId_1 = bdcheck.getBd_info().getID();
				if (str_sjxtId_1.equals(id)) {
					bdcheck.setIsChecked(true);
					// bdcheck.setContent(Other);
					break;
				}
			}
		}

		private void setData(RadioButtonViewHolder h, int position) {

			// 获取自定义的类实例
			tempGridViewItem = list_check.get(position);
			// android:focusable="false"
			h.rbButton.setOnCheckedChangeListener(null);
			h.rbButton.setChecked(tempGridViewItem.getIsChecked());

			h.rbButton.setText(tempGridViewItem.getBd_info().getDATAINFO());
			h.otherText.setText(tempGridViewItem.getContent());
			String str_datainfo = list_check.get(position).getBd_info().getDATAINFO();
			// if (str_datainfo.equals("有") || str_datainfo.equals("异常")) {
			// h.otherText.setVisibility(View.VISIBLE);
			// h.otherText.setEnabled(true);
			// h.otherText.addTextChangedListener(new
			// OnTextChangedListener(tempGridViewItem));
			// } else {
			h.otherText.setEnabled(false);
			// }

			h.rbButton.setOnCheckedChangeListener(this);

			h.rbButton.setTag(R.id.TAG, tempGridViewItem);

		}

		final class RadioButtonViewHolder {
			RadioButton rbButton;
			View choseView;
			EditText otherText;
		}

		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

			BD_DD_INFO_Checked check = (BD_DD_INFO_Checked) buttonView.getTag(R.id.TAG);
			for (BD_DD_INFO_Checked bdcheck : list_check) {
				bdcheck.setIsChecked(false);
				bdcheck.setContent("");
			}
			check.setIsChecked(isChecked);
			if (edittext != null) {
				if (getCheckedBD().getDATAINFO().equals("未戒酒")) {
					// checkedClear();
					// wuweihai();
					et_jiejiunianling.setText("");
					et_jiejiunianling.setEnabled(false);
				} else if (getCheckedBD().getDATAINFO().equals("已戒酒")) {
					// youweihai();
					et_jiejiunianling.setEnabled(true);
				}
			}

			if (getCheckedBD().getDATAINFO().equals("无")) {
				checkedClear();
				wuweihai();
			} else if (getCheckedBD().getDATAINFO().equals("有")) {
				youweihai();
			}
			notifyDataSetChanged();
		}

		private class OnTextChangedListener implements TextWatcher {
			private BD_DD_INFO_Checked w;

			public OnTextChangedListener(BD_DD_INFO_Checked w) {
				super();
				this.w = w;
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				String str_content = s.toString();
				w.setContent(str_content);
			}

		}
	}

	@Override
	public void save() {
		saveData();
	}

	/**
	 * 设置EditText是否可以输入
	 * 
	 * @param editText
	 * @param flag
	 *            true 可以输入；false 不可以输入
	 * @author 王婷婷
	 * @date 2016年5月6日 上午11:09:19
	 */
	private void setEditTextEnable(EditText editText, boolean flag) {
		editText.setFocusable(flag);
		editText.setEnabled(flag);
		editText.setFocusableInTouchMode(flag);
	}

	// Check
	/**
	 * 
	 * @param s
	 */
	private void yinJiuCheck(CharSequence s) {
		if (s != null && "从不".equals(s.toString())) {
			// TODO /fasdfa
			mgv_drink_type.setClickable(false);

			etDayDrinkVolume.setText("");// 日饮酒量
			etDayDrinkVolume.setEnabled(false);
			etDrinkStartAge.setText("");// 开始饮酒年龄
			etDrinkStartAge.setEnabled(false);

			if (drinkThisyearAdapter != null) {
				drinkThisyearAdapter.canCheck(false);
				drinkThisyearAdapter.clerChecked();// 最近一年
			}
			if (drinkTypeAdapter != null) {
				drinkTypeAdapter.clear();// 饮酒种类
				drinkTypeAdapter.canChecked(false);
			}
			if (drink != null) {
				drink.clerChecked();// 是否戒酒
				drink.canCheck(false);
			}
		} else {
			etDayDrinkVolume.setEnabled(true);
			etDrinkStartAge.setEnabled(true);
			if (drinkThisyearAdapter != null) {
				drinkThisyearAdapter.canCheck(true);
				// drinkThisyearAdapter.clerChecked();// 最近一年
			}
			if (drinkTypeAdapter != null) {
				// drinkTypeAdapter.clear();// 饮酒种类
				drinkTypeAdapter.canChecked(true);
			}
			if (drink != null) {
				// drink.clerChecked();// 是否戒酒
				drink.canCheck(true);
			}
		}
	}

	@Override
	public void onResume() {
		super.onResume();
		// initData();
	}

	public void ChecYear(final EditText et) {

		final int age = GlobalConts.getAge(userInfo.getBIRTHDAY());

		et.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if (!TextUtils.isEmpty(s.toString())) {
					int i = Integer.parseInt(s.toString());
					if (i > age) {
						((TiJianActivity) getActivity()).showTextDialog("年龄不能大于本人年龄");
						et.setText("");
					}

				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub

			}
		});

	}
}